define(['app'], function(app) {
	'use strict';
	
	//实例化方法
	var factory = function(Http) {
		/**
		 * 一键切换数据获取方式
		 * @param {Object} result
		 */
		function get_data_list(result) {
			if(false) {
				result = '{"success": true,"msg": "","result": {"store_count": "500","data": [' +
					'{"goods_id": 1,"name": "十字螺丝刀","introduce": "十字螺丝刀","price": 5.5,"mktprice": 8,' +
					'"preprice": 5.5,"store_id": "WuJin_1","store_name": "五金一店","image": "img/upload/pro-img01.jpg","storenumber": 100,' +
					'"salenumber": 20,"personlimit": 3,"qq": "1234567","phone": "18912345678","popularity":5000},' +
					'{"goods_id": 2,"name": "一字螺丝刀","introduce": "一字螺丝刀","price": 5.5,"mktprice": 8,' +
					'"preprice": 5.5,"store_id": "WuJin_1","store_name": "五金一店","image": "img/upload/pro-img01.jpg","storenumber": 80,' +
					'"salenumber": 10,"personlimit": 3,"qq": "1234567","phone": "18912345678","popularity":5000}]},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}
		//返回信息
		return {
			get_list: function( nPage,key, orderby, region, store_cat, callback,calldone) {
				//post请求
				Http.post({
					method: 'goods.search.getlist',
					cat_type: 8,
					key: key,
					orderby: orderby,
					region: region,
					store_cat: store_cat,
					pagelimit:20,
					nPage:nPage,
					picSize:'CS'
				}, function(result) {
					//函数回调
					if(callback)
						callback(get_data_list(result).result);
				}, function(err) {

				}, function() {
					if(calldone)
						calldone();
				});
			},
		};
	}

	factory.$inject = ['Http'];
	return app.registerService("Unsalablepro", factory);
});